home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / network / daemons / nfs / nfs-serv.2be / nfs-serv / nfs-server-2.2beta16 / profile.patch-2.0 < prev    next >
Encoding:
Text File  |  1995-06-14  |  3.2 KB  |  124 lines

  1.  
  2.     This is a patch against nfsd-2.0 that implements per-call
  3.     profiling of the nfs server. Apply this patch, compile with
  4.     -DCALL_PROFILING, run your favorite nfs benchmark and send
  5.     SIGIOT to nfsd. The averaged execution times per procedure
  6.     should be in /tmp/nfsd.profile.
  7.  
  8.     This patch is already incorporated in nfsd-2.2. If
  9.     you find that the stats for some calls differ significantly
  10.     between 2.0 and 2.2 versions, please let me know. I've had
  11.     a couple of reports about performance problems, but was not
  12.     able to pin them down.
  13.  
  14.     Olaf <okir@monad.swb.de>
  15.  
  16. --- dispatch.c.orig    Tue Dec 28 04:58:32 1993
  17. +++ dispatch.c    Thu May 18 00:07:47 1995
  18. @@ -105,6 +105,20 @@
  19.  
  20.  static _PRO( void set_ids, (struct svc_req *rqstp) );
  21.  
  22. +#ifdef CALL_PROFILING
  23. +#define PATH_PROFILE    "/tmp/nfsd.profile"
  24. +
  25. +static struct timeval    rtimes[18] = {
  26. +    {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0},
  27. +    {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0},
  28. +    {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}
  29. +};
  30. +static int        calls[18] = {
  31. +    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  32. +};
  33. +static struct timeval    t0, t1;
  34. +#endif
  35. +
  36.  void nfs_dispatch(rqstp, transp)
  37.  struct svc_req *rqstp;
  38.  SVCXPRT *transp;
  39. @@ -129,6 +143,10 @@
  40.      /* Log the call. */
  41.      log_call(rqstp, dent->name, dent->log_print(&argument));
  42.  
  43. +#ifdef CALL_PROFILING
  44. +    gettimeofday(&t0, NULL);
  45. +#endif
  46. +
  47.      /* Initialize our variables for determining the attributes of
  48.         the file system in nfsd.c */
  49.      svc_rqstp = rqstp;
  50. @@ -162,7 +180,51 @@
  51.          dprintf(0, "unable to free RPC arguments, exiting\n");
  52.          exit(1);
  53.      }
  54. +#ifdef CALL_PROFILING
  55. +    gettimeofday(&t1, NULL);
  56. +
  57. +    if (t1.tv_usec < t0.tv_usec) {
  58. +        rtimes[proc_index].tv_sec += t1.tv_sec - t0.tv_sec - 1;
  59. +        rtimes[proc_index].tv_usec += 1000000 + t1.tv_usec - t0.tv_usec;
  60. +    } else {
  61. +        rtimes[proc_index].tv_sec += t1.tv_sec - t0.tv_sec;
  62. +        rtimes[proc_index].tv_usec += t1.tv_usec - t0.tv_usec;
  63. +    }
  64. +    calls[proc_index]++;
  65. +#endif
  66. +
  67. +}
  68. +
  69. +#ifdef CALL_PROFILING
  70. +void
  71. +dump_stats(int sig)
  72. +{
  73. +    FILE    *fp;
  74. +    int    i;
  75. +
  76. +    signal (sig, dump_stats);
  77. +
  78. +    if ((fp = fopen(PATH_PROFILE, "w")) == NULL) {
  79. +        dprintf(0, "unable to write profile data to %s\n",
  80. +                PATH_PROFILE);
  81. +        return;
  82. +    }
  83. +
  84. +    for (i = 0; i < 18; i++) {
  85. +        float t;
  86. +
  87. +        t = (float) rtimes[i].tv_sec +
  88. +            (float) rtimes[i].tv_usec / 1000000.0;
  89. +        fprintf(fp, "%-20s\t%5d calls %8.4f sec avg\n",
  90. +                dtable[i].name, calls[i],
  91. +                (calls[i])?  t / calls[i] : 0);
  92. +        rtimes[i].tv_sec = rtimes[i].tv_usec = 0;
  93. +        calls[i] = 0;
  94. +    }
  95. +
  96. +    fclose (fp);
  97.  }
  98. +#endif
  99.  
  100.  static void set_ids(rqstp)
  101.  struct svc_req *rqstp;
  102. --- nfsd.c.orig    Thu May 18 00:08:12 1995
  103. +++ nfsd.c    Thu May 18 00:09:15 1995
  104. @@ -50,6 +50,9 @@
  105.  static _PRO(nfsstat build_path, (char *buf, diropargs * da));
  106.  static _PRO(int makesock, (int port, int proto, int socksz));
  107.  static _PRO(void closedown, (int sig));
  108. +#ifdef CALL_PROFILING
  109. +extern _PRO(void dump_stats, (int sig));
  110. +#endif
  111.  
  112.  extern void xdr_free();        /* fill this in later */
  113.  extern void pmap_unset();    /* why here??? */
  114. @@ -953,6 +956,9 @@
  115.  
  116.      /* Enable the LOG toggle with a signal. */
  117.      signal(SIGUSR1, toggle_logging);
  118. +#ifdef CALL_PROFILING
  119. +    signal(SIGIOT, dump_stats);
  120. +#endif
  121.  
  122.      if (_rpcpmstart) {
  123.          signal(SIGALRM, closedown);
  124.